@include('admin.public.head')
<link href="{{ URL::asset('./admin/css/main.css') }}" rel="stylesheet">
<style>
* {
    -webkit-box-sizing: initial;
    box-sizing: initial;
}
</style>
<body class="gray-bg">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page wrapper wrapper-content animated fadeInRight">
	<div class="flexigrid">
		<div class="mDiv">
			<div class="ftitle">
				<h3>权限管理</h3>
			</div>
		</div>
		<div class="hDiv">
			<div class="hDivBox">
				<table cellspacing="0" cellpadding="0">
					<thead>
					<tr>
						<th class="sign" axis="col0" >
							<div style="width: 24px;"><i class="ico-check"></i></div>
						</th>
						<th align="left" abbr="article_title" axis="col3" class="">
							<div style="text-align: left; width: 100px;" class="">ID</div>
						</th>
						<th align="left" abbr="ac_id" axis="col4" class="">
							<div style="text-align: left; width: 200px;" class="">用户名称</div>
						</th>
						<th align="center" abbr="article_show" axis="col5" class="">
							<div style="text-align: left; width: 200px;" class="">IP</div>
						</th>
						<th align="center" abbr="article_show" axis="col5" class="">
							<div style="text-align: left; width: 200px;" class="">URL</div>
						</th>
						<th align="center" abbr="article_show" axis="col5" class="">
							<div style="text-align: left; width: 200px;" class="">Browser</div>
						</th>
						<th align="center" abbr="article_show" axis="col5" class="">
							<div style="text-align: left; width: 200px;" class="">创建时间</div>
						</th>
						<th align="center" axis="col1" class="handle">
							<div style="text-align: center; width: 150px;">操作</div>
						</th>
						<th style="width:100%" axis="col7">
							<div></div>
						</th>
					</tr>
					</thead>
				</table>
			</div>
		</div>
		<div class="tDiv">
			<div class="tDiv2">
				<div class="fbutton">
					<a href="/add_role">
						<div class="add" title="添加角色">
							<span><i class="fa fa-plus"></i>删除</span>
						</div>
					</a>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="bDiv" style="height: auto;">
			<div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
				<table>
					<tbody>
					@foreach($data as $vo)
						<if condition="gt 1">
							<tr>
								<td class="sign">
									<div style="width: 24px;"><i class="ico-check"></i></div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 100px;">{{$vo->id}}</div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 200px;">{{$vo->name}}</div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 200px;">{{$vo->ip}}</div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 200px;">{{$vo->url}}</div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 200px;">{{$vo->useragent}}</div>
								</td>
								<td align="left" class="">
									<div style="text-align: left; width: 200px;">{{ date('Y-m-d H:i:s',$vo->created_at)  }}</div>
								</td>
								<td align="center" class="handle">
									<div style="text-align: center; width: 170px; max-width:170px;">
										<a href="#" url="/power/{{$vo->id}}" onclick="toggle($(this), '查看')"  class="btn blue"><i class="fa fa-pencil-square-o"></i>查看</a>
										<a class="btn red"  href="javascript:void(0)" url="/powerDelete/{{$vo->id}}"  onclick="delfun(this)"><i class="fa fa-trash-o"></i>删除</a>
									</div>
								</td>
								<td align="" class="" style="width: 100%;">
									<div>&nbsp;</div>
								</td>
							</tr>
						</if>
					@endforeach
					</tbody>
				</table>
			</div>
			<div class="iDiv" style="display: none;"></div>
		</div>
		{{$data->links()}}
		<!--分页位置-->
	 </div>
</div>
<script>
	$(document).ready(function(){
		// 表格行点击选中切换
		$('#flexigrid > table>tbody >tr').click(function(){
			$(this).toggleClass('trSelected');
		});

		// 点击刷新数据
		$('.fa-refresh').click(function(){
			location.href = location.href;
		});

	});

	function toggle(obj, name) {
		var url = obj.attr('url');

		//自定页
		parent.layer.open({
			type: 2,
			title: `日志${name}`,
			skin: 'layui-layer-rim', //加上边框
			area: ['800px', '600px'], //宽高
			content: [url, 'yes']
		});
	}


	function delfun(obj) {
		var index = layer.confirm('是否确认删除!', {
		  btn: ['确认','取消'] //按钮
		}, function(){
		  	var url = $(obj).attr('url');
			$.ajax({
                url:url,    //请求的url地址
                dataType:"json",   //返回格式为json
                type:"POST",   //请求方式
                success:function(req){
                    //请求成功时处理
                    if(req.status == 0){
                        layer.msg(req.message);
                        return false;
                    }

                    layer.msg('操作成功！');
	                setTimeout(function(){
	                    window.location.href = "/power";
	                },500);
                }
            });

		}, function(){
			alert('取消操作');
		  	// layer.closer(index);
		});
	}
</script>
</body>
</html>
